local tooltip
local function generateTooltip()
	tooltip = CreateFrame("GameTooltip", "cargBagsTooltip")
	tooltip:SetOwner( WorldFrame, "ANCHOR_NONE" ) 
	tooltip:AddFontStrings( 
		tooltip:CreateFontString("$parentTextLeft1", nil, "GameTooltipText"), 
		tooltip:CreateFontString("$parentTextRight1", nil, "GameTooltipText")
	)
	return tooltip
end

cargBags.ItemKeys["bindOn"] = function(i)
	if(not i.link) then return end
	tooltip = tooltip or generateTooltip()
	tooltip:SetHyperlink(i.link)
	local bound = cargBagsTooltipTextLeft2:GetText()
	if(not bound) then return end

	local bindOn
	if(bound:match(ITEM_BIND_ON_EQUIP)) then bindOn = "equip"
	elseif(bound:match(ITEM_BIND_QUEST)) then bindOn = "quest"
	elseif(bound:match(ITEM_BIND_TO_ACCOUNT)) then bindOn = "account"
	elseif(bound:match(ITEM_BIND_ON_PICKUP)) then bindOn = "pickup"
	elseif(bound:match(ITEM_BIND_ON_USE)) then bindOn = "use" end
	i.bindOn = bindOn
	return bindOn
end

cargBags.ItemKeys["stats"] = function(i)
	if(not i.link or not GetItemStats) then return end
	local stats = GetItemStats(i.link)
	i.stats = stats
	return stats
end
